import java.util.*;

public class Market{
    public static Set<Car> cars = new HashSet<Car>();
    public static Map<Certificate, Person> people  = new HashMap<Certificate, Person>();

    public static void addPerson(Person p){
       people.put(p.getCode(), p); 
    }

    public static void addCar(Car car){
        cars.add(car);
    }

    public static boolean sellCar(Person p1, Car car, Person p2){
        
        if(car ==null){
            //p2 buy all cars from p1
           int size = p1.getCars().size();
           for(int i=0;i<size;i++){
                Car c = p1.getCars().get(i);
                p1.sellCar(c);
                p2.buyCar(c,p2);
           } 
        }else{
            //p1  sell car to p2
            p1.sellCar(car);
            p2.buyCar(car,p2);
        }

        return true;
    }


}
